package com.cn.项目.飞机预约管理系统.Maininterface;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

//公告管理

public class Announcement extends JPanel implements ActionListener {
    JPanel p3 = null;
    public Announcement(){
        JPanel p1 = new JPanel();
        p1.setLayout(new BorderLayout());
        JPanel p2 = new JPanel();
        p1.add(p2,"North");
        p2.setLayout(new GridLayout(1,2,50,0));
        JButton j1 = new JButton("设置公告");
        j1.addActionListener(this);
        JButton j2 = new JButton("显示公告");
        j2.addActionListener(this);

        p2.add(j1);
        p2.add(j2);
        p3 = new JPanel();
        p1.add(p3,"Center");

        this.add(p1);
        this.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getActionCommand()=="设置公告"){
            p3.setVisible(false);
            p3.removeAll();
            p3.add(new SetAnnouncement());
            p3.setVisible(true);
        }


        if (e.getActionCommand()=="显示公告"){
            p3.setVisible(false);
            p3.removeAll();
           p3.add(new Showannouncement());

            p3.setVisible(true);
        }

    }
}
